<template>
  <div class="data-table">
    <Table :columns="columns"
           :data="items">
      <template v-for="item in columns"
                slot-scope="{row,index}"
                :slot="item.slot">
        <component v-if="item.component"
                   :key="item.id"
                   :is="item.component"
                   v-bind="item.config"></component>
        <span v-else>{{ row[item.slot] }}</span>
      </template>
    </Table>
  </div>
</template>

<script>
  import {isObject} from 'lodash'

  export default {
    name: "DataTable",
    computed: {
      thead() {
      },
      items() {
        if (isObject(this.data)) {
          return Object.values(this.data)
        }
        return this.data
      }
    },
    props: {
      columns: {
        type: Array,
        require: true
      },
      data: {
        require: true,
        default() {
          return []
        }
      }
    }
  }
</script>

<style scoped>

</style>